package com.ebelter.btlibrary.btble.impl.tmm;

import com.ebelter.btlibrary.btble.ble.bluetooth.device.impl.BleCommandEditor;
import com.ebelter.btlibrary.btble.impl.scale.model.ScaleCommand;
import com.ebelter.btlibrary.btble.impl.tmm.callback.TmmCommand;
import com.ebelter.btlibrary.util.ULog;

/**
 * 耳温枪指令编辑器实现层
 * Created by Sergio Pan on 2017/12/8.
 */

public class TmmCommondEditor extends BleCommandEditor {

    private static final String TAG = "TmmCommondEditor";

    private static TmmCommondEditor instance = new TmmCommondEditor();

    private TmmCommondEditor() {
    }

    public static TmmCommondEditor getInstance() {
        return instance;
    }



    @Override
    protected void onReceiveCommand(Object command) {
        TmmCommand tmmCommand = (TmmCommand) command;
        ULog.i(TAG, "-------onReceiveCommand-------tmmCommand = " + tmmCommand);
        switch (tmmCommand){
            case RECEIVED:
                receivedAndStopDeviceSend();
                break;

        }
    }



    /**
     * 数据接收成功，请求设备停止发送
     */
    public void receivedAndStopDeviceSend() {
        ULog.i(TAG, "send received, and request device stop send cmd.");
        byte[] bytes = {dataHeaderSend, 0x29};
        sendBleMessage(bytes);
    }

    /**
     * 关闭蓝牙和设备
     */
    public void closeDevice() {
        ULog.i(TAG, "send close Device cmd.");
        byte[] bytes = {dataHeaderSend, 0x30};
        sendBleMessage(bytes);
    }

}
